<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="format-detection" content="telephone=no">
    <meta content="yes" name="apple-touch-fullscreen"/>
    <title>商品详情</title>
    <link rel="stylesheet" href="/static/css/base.css?v={$staticVersion}"/>
    <link rel="stylesheet" type="text/css" media="screen" href="/static/css/swiper-3.3.1.min.css" />
    <link rel="stylesheet" href="/static/css/groupbuying.css?v={$staticVersion}"/>
</head>
<body>
    <div class="swiper-container">
        <div class="swiper-wrapper">
            {loop $groupon['images'] $k $v}
            <div class="swiper-slide">
                <div class="swiper-zoom-container">
                    <img src="$v" width="300" height="300">
                </div>
            </div>
            {/loop}
        </div>
        <!-- Add Pagination -->
        <div class="swiper-pagination swiper-pagination-white"></div>
    </div>
    <h2 class="commodity-name p10">{$groupon['title']}</h2>
    <section class="sale-time">
        <span class="sale">￥{$groupon['low_price']}</span>
        <span class="font-up">起</span>
        <span class="original">
            <small>￥{$groupon['cost_price']}</small>
            {$groupon['num_msg']}
        </span>
        {if $groupon['type']==3&&$groupon['gear_id']}
            <p style="position:absolute;padding-top:7px;right:10px;font-size:14px;bottom:1px;">
            <i id="iwant" class="star" data-id="{$groupon['gear_id']}" data-action="query"></i>收藏
            </p>
        {else}
            <p class="time" data-endtime="{$groupon['end_time']}"  data-prefix="$groupon['button']['status_msg']"></p>
        {/if}
    </section>
    <a class="guarantee p10 db" href="grouponApprove"><img src="/static/images/img/sb.jpg"></a>
    {if $groupon['type']==2}
    <dl class="groupon-info">
        <dt>如何参加团购</dt>
        <dd>●　告知店家“<span class="color-red">团购</span>”及“<span class="color-red">虎扑跑步</span>”，即可享受团购价</dd>
    </dl>
    {/if}
    <section class="commodity-info">
            $groupon['image_content']
            <p></p>
            <p></p>
            <p></p>
    </section>
    {if !empty($groupon['good_list'])}
    <section class="masklayer" style="display: none;">
        <div class="choice-box">
            <section class="sp-header">
                <img id="chooseimg" >
                <p>
                    <span class="price" id="chooseprice">￥{$groupon['low_price']}</span><br/>
                    还剩<em id="choosenum">{$groupon['num']}</em>件<br/>
                    <span id="choosetext">请选择 
                    {loop $groupon['good_list']['attrs'] $k $v}
                    $v['headInfo']['title']
                    {/loop}
                    </span>
                </p>
            </section>
            <dl>
                {loop $groupon['good_list']['attrs'] $k $v}
                <dt>$v['headInfo']['title']</dt>
                <dd>
                    {loop $v['attrValue'] $m $f}
                    <span class="_color" data-pid="$v['headInfo']['id']" data-id="$f['id']" data-img="$f['img_source']">$f['title']</span>
                    {/loop}
                </dd>
                {/loop}
                <dt>购买数量</dt>
                <dd class="num-box">
                   <span>-</span>
                   <input type="text" name="" placeholder="0" value="1" readonly="true">
                   <span>+</span>
                </dd>
            </dl>
            <a class="order-confirm _buyconfirm">确定</a>
        </div>
    </section>
    {/if}

    {if $groupon['type']==2||$groupon['status']!=5}
    <span data-url="$groupon['url']" class="_buybutton buy-btn $groupon['button']['buy1_class']">{$groupon['button']['buy1']}</span>
    {else}
    <section class="bottom-box">
        <a href="/show/shoppingCart"><span class="icon-cart">购物车</span></a>
        <button class="add-cart _buybutton" data-shopcart="true">加入购物车</button>
        <button class="buy-now _buybutton">立即购买</button>
    </section>
    {/if}
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/mod.js"></script>
<script src="/static/summary/swiper-3.4.1.min.js"></script>
<script src="/static/summary/swiper.animate1.0.2.min.js"></script>
<script src="/static/js/show/gear.js?v={$staticVersion}"></script>

<script type="text/javascript">
    var isNewVersion = $isNewVersion;
    var swiper = new Swiper('.swiper-container', {
        zoom: true,
        pagination: '.swiper-pagination',
        nextButton: '.swiper-button-next',
        prevButton: '.swiper-button-prev'
    });

    var goods = $goods;
    var isShare = $isShare;
    var flash_id = $groupon['id'];

    var default_img = $('.choice-box ._color').eq(0).attr('data-img');
    if (default_img==''){
        default_img = $('.swiper-zoom-container img').eq(0).attr('src');
    }
    $('#chooseimg').attr('src',default_img);

    var defalt_text = $('#choosetext').text();
    var defalt_price = $('#chooseprice').text();
    var defalt_num = $('#choosenum').text();
    var gid = '';
    var isaddtocart=null;

     $('._buyconfirm').on('click',function(){
        if(gid==''){
            toast('请先择款式',isNewVersion);
        }else if(isaddtocart=='true') {
            $.ajax({
                url: "/gearWeb/addshopCart?act=add",
                data: { 'ogid': gid, 'num': $('.num-box input').val(),'aid':flash_id},
                context: document.body,
                dataType:'json'
            }).done(function(data){
                if(data.error&&data.error.id==201){
                    location.href = "joggers://login/";
                    return;
                }
                if(data.result==-1){
                    toast('购物车数量已达上限，先去清理购物车吧',isNewVersion);
                }else if(data.result==-2){
                    toast('商品数量不足或超出购买限制',isNewVersion);
                }else {
                    $('.masklayer').click();
                    toast('你选择的商品已加入购物车',isNewVersion);
                }
            }).error(function() {
                toast('error',isNewVersion);
            });
        }else{
            var num = $('.num-box input').val();
            window.location = 'joggers://order/goodsDetail?atype=flashSales&goods_id='+gid+'&aid=$groupon["id"]&num='+num;
        }
    });

    initskubutton();

    if(isShare) {
           $(".buy-btn").html("下载虎扑跑步APP参加 精彩活动");
           $('.buy-btn').click(function(){
                 window.location.href='http://a.mlinks.cc/Aagr?url={$mlink}';
           })
    }


    $(function(){
      if(typeof jw === "object") {
        jw.api('share_button', JSON.stringify({'status': true}));
        jw.api('set_share_info', JSON.stringify({
          'title': '虎扑跑步限时闪购',
          'description': '',
          'img_url': $('.swiper-wrapper img').eq(0).attr('src'),
          'link_url':'{$staticHost}/show/flashSales?saleId='+$groupon['id'],
        }));
      }
   });

iwant();
starttimer({$current_time});

</script>
</body>
{template 'show/web-gearfooter'}
<script type="text/javascript">
    if(typeof jw === "object" ) {
        jw.api('wv_setnav', JSON.stringify({
            "title": '',
            "nav": getNav([$shopcart,1])
        }), '')
    }
</script>